home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWTBitVec.z / RWTBitVec
Encoding:
Text File  |  1998-10-30  |  10.1 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))                                                RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTBitVec<size> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/tbitvec.h>
  13.  
  14.  
  15.  
  16.               RWTBitVec<22>   // A 22 bit long vector
  17.  
  18.  
  19.  
  20.  
  21. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  22.      RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc<<<<ssssiiiizzzzeeee>>>> is a parameterized bit vector of fixed length ssssiiiizzzzeeee.
  23.      Unlike class RRRRWWWWBBBBiiiittttVVVVeeeecccc, its length cannot be changed at run time.  The
  24.      advantage of RRRRWWWWBBBBiiiittttVVVVeeeecccc is its smaller size, and one less level of
  25.      indirection, resulting in a slight speed advantage.  Bits are numbered
  26.      from 0 through ssssiiiizzzzeeee----1111, inclusive.  The copy constructor and assignment
  27.      operator use ccccooooppppyyyy semantics.
  28.  
  29. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  30.      None
  31.  
  32. EEEExxxxaaaammmmpppplllleeee
  33.      In this example, a bit vector 24 bits long is exercised:
  34.  
  35.               #include <rw/tbitvec.h>
  36.  
  37.  
  38.  
  39.               main()  {
  40.             RWTBitVec<24> a, b;      // Allocate two vectors.
  41.             a(2) = TRUE;             // Set bit 2 (the third bit) of a on.
  42.             b(3) = TRUE;             // Set bit 3 (the fourth bit) of b on.
  43.             RWTBitVec<24> c = a ^ b; // Set c to the XOR of a and b.
  44.           }
  45.  
  46.  
  47.  
  48. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr
  49.               RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc<<<<ssssiiiizzzzeeee>>>>();
  50.  
  51.  
  52.      Constructs an instance with all bits set to FFFFAAAALLLLSSSSEEEE.
  53.  
  54.               RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc<<<<ssssiiiizzzzeeee>>>>(RWBoolean val);
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))                                                RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      Constructs an instance with all bits set to vvvvaaaallll.
  75.  
  76. AAAAssssssssiiiiggggnnnnmmmmeeeennnntttt OOOOppppeeeerrrraaaattttoooorrrrssss
  77.               RWTBitVec<size>&
  78.           ooooppppeeeerrrraaaattttoooorrrr====(const RWTBitVec<size>& v);
  79.  
  80.  
  81.      Sets self to a copy of vvvv.
  82.  
  83.               RWTBitVec&
  84.           ooooppppeeeerrrraaaattttoooorrrr====(RWBoolean val);
  85.  
  86.  
  87.      Sets all bits in self to the value vvvvaaaallll.
  88.  
  89.               RWTBitVec&
  90.           ooooppppeeeerrrraaaattttoooorrrr&&&&====(const RWTBitVec& v);
  91.           RWTBitVec&
  92.           ooooppppeeeerrrraaaattttoooorrrr^^^^====(const RWTBitVec& v);
  93.           RWTBitVec&
  94.           ooooppppeeeerrrraaaattttoooorrrr||||====(const RWTBitVec& v);
  95.  
  96.  
  97.      Logical assignments.  Sets each bit of self to the logical AAAANNNNDDDD, XXXXOOOORRRR, or
  98.      OOOORRRR, respectively, of self and the corresponding bit in vvvv.
  99.  
  100.               RWBitRef
  101.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
  102.  
  103.  
  104.      Returns a reference to the iiiith bit of self.  This reference can be used
  105.      as an lvalue.  The index iiii must be between 0000 and ssssiiiizzzzeeee----1111, inclusive.
  106.      Bounds checking will occur.
  107.  
  108.               RWBitRef
  109.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i);
  110.  
  111.  
  112.      Returns a reference to the iiiith bit of self.  This reference can be used
  113.      as an lvalue.  The index iiii must be between 0000 and ssssiiiizzzzeeee----1111, inclusive.  No
  114.      bounds checking is done.
  115.  
  116. LLLLooooggggiiiiccccaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss
  117.               RWBoolean
  118.           ooooppppeeeerrrraaaattttoooorrrr========(RWBoolean b) const;
  119.  
  120.  
  121.      Returns TTTTRRRRUUUUEEEE if every bit of self is set to the value bbbb.  Otherwise,
  122.      returns FFFFAAAALLLLSSSSEEEE.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))                                                RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               RWBoolean
  141.           ooooppppeeeerrrraaaattttoooorrrr!!!!====(RWBoolean b) const;
  142.  
  143.  
  144.      Returns TTTTRRRRUUUUEEEE if any bit of self is not set to the value bbbb.  Otherwise,
  145.      returns FFFFAAAALLLLSSSSEEEE.
  146.  
  147.               RWBoolean
  148.           ooooppppeeeerrrraaaattttoooorrrr========(const RWTBitVec& v) const;
  149.  
  150.  
  151.      Returns TTTTRRRRUUUUEEEE if each bit of self is set to the same value as the
  152.      corresponding bit in vvvv.  Otherwise, returns FFFFAAAALLLLSSSSEEEE.
  153.  
  154.               RWBoolean
  155.           ooooppppeeeerrrraaaattttoooorrrr!!!!====(const RWTBitVec& v) const;
  156.  
  157.  
  158.      Returns TTTTRRRRUUUUEEEE if any bit of self is not set to the same value as the
  159.      corresponding bit in vvvv.  Otherwise, returns FFFFAAAALLLLSSSSEEEE.
  160.  
  161.               void
  162.           cccclllleeeeaaaarrrrBBBBiiiitttt(size_t i);
  163.  
  164.  
  165.      Clears (iiii....eeee...., sets to FFFFAAAALLLLSSSSEEEE) the bit with index iiii.  The index iiii must be
  166.      between 0 and ssssiiiizzzzeeee----1111.  No bounds checking is performed.  The following
  167.      two lines are equivalent, although cccclllleeeeaaaarrrrBBBBiiiitttt((((ssssiiiizzzzeeee____tttt)))) is slightly smaller
  168.      and faster than using ooooppppeeeerrrraaaattttoooorrrr(((())))((((ssssiiiizzzzeeee____tttt)))):
  169.  
  170.                  a(i) = FALSE;
  171.  
  172.  
  173.  
  174.                  a.clearBit(i);
  175.  
  176.  
  177.  
  178.  
  179.               const RWByte*
  180.           ddddaaaattttaaaa() const;
  181.  
  182.  
  183.      Returns a ccccoooonnnnsssstttt pointer to the raw data of self.  Should be used with
  184.      care.
  185.  
  186.               size_t
  187.           ffffiiiirrrrssssttttFFFFaaaallllsssseeee() const;
  188.  
  189.  
  190.      Returns the index of the first OOOOFFFFFFFF (False) bit in self.  Returns RRRRWWWW____NNNNPPPPOOOOSSSS
  191.      if there is no OOOOFFFFFFFF bit.
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))                                                RRRRWWWWTTTTBBBBiiiittttVVVVeeeecccc((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               size_t
  207.           ffffiiiirrrrssssttttTTTTrrrruuuueeee() const;
  208.  
  209.  
  210.      Returns the index of the first OOOONNNN (True) bit in self.  Returns RRRRWWWW____NNNNPPPPOOOOSSSS if
  211.      there is no OOOONNNN bit.
  212.  
  213.               void
  214.           sssseeeettttBBBBiiiitttt(size_t i);
  215.  
  216.  
  217.      Sets (iiii....eeee...., sets to TTTTRRRRUUUUEEEE) the bit with index iiii.  The index iiii must be
  218.      between 0 and ssssiiiizzzzeeee----1111.  No bounds checking is performed.  The following
  219.      two lines are equivalent, although sssseeeettttBBBBiiiitttt((((ssssiiiizzzzeeee____tttt)))) is slightly smaller and
  220.      faster than using ooooppppeeeerrrraaaattttoooorrrr(((())))((((ssssiiiizzzzeeee____tttt))))
  221.  
  222.                 a(i) = TRUE;
  223.  
  224.  
  225.  
  226.                 a.setBit(i);
  227.  
  228.  
  229.  
  230.  
  231.               RWBoolean
  232.           tttteeeessssttttBBBBiiiitttt(size_t i) const;
  233.  
  234.  
  235.      Tests the bit with index iiii.  The index iiii must be between 0 and ssssiiiizzzzeeee----1111.
  236.      No bounds checking is performed.  The following are equivalent, although
  237.      tttteeeessssttttBBBBiiiitttt((((ssssiiiizzzzeeee____tttt)))) is slightly smaller and faster than using
  238.      ooooppppeeeerrrraaaattttoooorrrr(((())))((((ssssiiiizzzzeeee____tttt)))):
  239.  
  240.                 if( a(i) ) doSomething();
  241.  
  242.  
  243.  
  244.                 if( a.testBit(i) ) doSomething();
  245.  
  246.  
  247.  
  248. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll FFFFuuuunnnnccccttttiiiioooonnnnssss
  249.               RWTBitVec ooooppppeeeerrrraaaattttoooorrrr&&&&(const RWTBitVec& v1, const RWTBitVec& v2);
  250.           RWTBitVec ooooppppeeeerrrraaaattttoooorrrr^^^^(const RWTBitVec& v1, const RWTBitVec& v2);
  251.           RWTBitVec ooooppppeeeerrrraaaattttoooorrrr||||(const RWTBitVec& v1, const RWTBitVec& v2);
  252.  
  253.  
  254.      Return the logical AAAANNNNDDDD, XXXXOOOORRRR, and OOOORRRR, respectively, of vectors vvvv1111 and vvvv2222.
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.